package com.yuanian.timingwheel.test;

import com.yuanian.timingwheel.annotation.TaskHandler;
import com.yuanian.timingwheel.annotation.TimingTask;
import com.yuanian.timingwheel.annotation.TimingTaskType;
import com.yuanian.timingwheel.model.task.build.TaskExecutionBuilder;
import com.yuanian.timingwheel.model.task.build.adapter.FixedDateTaskExecutionAdapter;
import org.springframework.stereotype.Component;

import java.util.Date;

//@TaskHandler
public class PurService {

    //TimingTaskType.AUTO为项目启动自动加入
    @TimingTask(dynamicParamSolver = "dynamicSolver", timingTaskType = TimingTaskType.AUTO)
    public void dayHandler() {
        System.out.println("xxxxxxxx");
    }

    public TaskExecutionBuilder dynamicSolver() {
        return new FixedDateTaskExecutionAdapter() {

            @Override
            public Date executionTime() {
                return new Date(new Date().getTime() + 30 * 1000);
            }

            @Override
            public String taskDesc() {
                return "test";
            }

            @Override
            public String businessId() {
                return "test01";
            }

        };
    }

}
